#低筒和高通滤波

import cv2
import numpy as np

#均值滤波
def mean_filter():
    img = cv2.imread("./surprise.jpg")
    img_mean = cv2.blur(img, (5, 5))
    cv2.imshow("Mean Filter", img_mean)
    cv2.waitKey(0)

#高斯滤波
def gaussian_filter():
    img = cv2.imread("./surprise.jpg")
    img_gaussian = cv2.GaussianBlur(img, (9, 9), sigmaX =3)
    cv2.imshow("img_gaussian", img_gaussian)
    cv2.waitKey(0)

#中值滤波
def median_filter():
    img = cv2.imread("./surprise.jpg")
    img_median = cv2.medianBlur(img, 5)
    cv2.imshow("Median Filter", img_median)
    cv2.waitKey(0)

#双边滤波
def bilateral_filter():
    img = cv2.imread("./surprise.jpg")
    img_bilateral = cv2.bilateralFilter(img, 9, 75, 75)
    cv2.imshow("Bilateral Filter", img_bilateral)
    cv2.waitKey(0)


#高通滤波 sobel算子
def high_pass_filter():
    img = cv2.imread("./surprise.jpg")
    d1 = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize =5)
    d2 = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize =5)
    d = cv2.add(d1, d2)
    cv2.imshow("d", d)
    cv2.waitKey(0)

#拉普拉斯算子 ,需要自己进行去噪
def laplacian_filter():
    img = cv2.imread("./surprise.jpg")
    #去噪操作
    img = cv2.medianBlur(img, 5)
    img_laplacian = cv2.Laplacian(img, cv2.CV_64F, ksize =5)
    cv2.imshow("Laplacian Filter", img_laplacian)
    cv2.waitKey(0)

#canny算子 ,使用的5*5高斯滤波除噪，然偶进行图像梯度计算，取局部极大值，最后进行阈值分割
def canny_filter():
    img = cv2.imread("./surprise.jpg")
    canny_img = cv2.Canny(img, 30, 110)
    cv2.imshow("Canny Filter", canny_img)
    cv2.waitKey(0)


if __name__ == '__main__':
    canny_filter()